<template>
	<div class="NoticeOfShipment">
		<div class="function">
			<el-row :gutter="10">
				<el-col :span="2.2">
					<el-button type="primary" @click="add">
						<img src="../../../assets/img/add.png" class="iconw">
						新增发货通知单
					</el-button>
				</el-col>
				<el-col :span="2">
					<el-button type="primary" @click="changeHis">
						<img src="../../../assets/img/cx2.png" class="iconw">
						历史发货通知单查询
					</el-button>
				</el-col>
			</el-row>
		</div>
		    <el-carousel height="72vh" :initial-index='0' :autoplay="false" indicator-position="none" arrow="never" ref="swip">
		      <el-carousel-item>
				<div class="from">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="4">
								<el-form-item label="订单编号：" prop="fOrgCategory">
									<el-input  v-model="from.tableHead.salesOrderHead.fOrderCode" />
								</el-form-item>
							</el-col>
							<el-col :span="1">
								<el-button type="primary" @click="changeAdd">…</el-button>
							</el-col>
							<el-col :span="5">
								<el-form-item label="客户编号：" prop="fOrgCategory">
									<el-input v-model="from.tableHead.salesOrderHead.fCustomerCode" @keyup.enter="select_name" />
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="客户名称：" prop="fOrgCategory">
									<el-input placeholder="请输入客户名称" disabled v-model="from.tableHead.salesOrderHead.fCustomerName" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
<!-- 								<el-form-item label="通知单号：" prop="fOrgCategory">
									<el-input disabled  v-model="from.tableHead.salesOrderHead.fOrderNumber" />
								</el-form-item> -->
							</el-col>
							<el-col :span="4">
<!-- 								<el-form-item label="通知单日期：" prop="fOrgCategory">
									<el-date-picker disabled type="date" v-model="from.tableHead.salesOrderHead.fOrderDate" />
								</el-form-item> -->
							</el-col>
							<el-col :span="12">
								<el-form-item label="收货地址：" prop="fOrgCategory">
									<el-input  v-model="from.tableHead.salesOrderHead.fCusReceiveAddress" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="通知单号：" prop="saleorder">
									<el-input disabled  v-model="from.tableHead.salesOrderHead.saleorder" />
								</el-form-item>
							</el-col>
							<el-col :span="8"></el-col>
							<el-col :span="4">
								<el-form-item label="发 货 日 期 ：" prop="fOrgCategory">
									<el-date-picker type="date" value-format="YYYY-MM-DD" v-model="from.tableHead.salesOrderHead.fSendDate" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="收货方：" prop="fOrgCategory">
									<el-input  v-model="from.tableHead.salesOrderHead.fSender" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label=" 经  办 人 ： " prop="fOrgCategory">
									<el-input  v-model="from.tableHead.salesOrderHead.fAgent" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="经办人电话：" prop="fOrgCategory">
									<el-input placeholder="请输入经办人电话" v-model="from.tableHead.salesOrderHead.fAgentPhone" />
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="发货物流：" prop="fOrgCategory">
									<el-input placeholder="请输入发货物流" v-model="from.tableHead.salesOrderHead.fSendLogistics" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<div style="width:100%;height: 100%;display: flex;justify-content: flex-end;">
									<el-button type="primary" style="width: 74%;" plain @click="confirmOrder">
										<!-- (from.tableHead.salesOrderVos.length<=0)?(''):(confirmOrder()) -->
										确认通知单
									</el-button>
								</div>
							</el-col>
						</el-row>
					</div>
				</div>
				<div class="table">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								<el-table :data="from.tableHead.salesOrderVos" border style="width: 100%" @row-dblclick="dbclick">
									<el-table-column prop="fInvCode" label="物料编号" #default="scope">
										<el-input v-model="scope.row.fInvCode" @keyup.enter="SM_wlbh(scope)"></el-input>
										<!-- (from.tableHead.salesOrderHead.fOrderCode.length>0)?(from.tableHead.salesOrderVos.push({})):('') -->
									</el-table-column>

									<el-table-column prop="fInvName" label="物料名称" />

									<el-table-column prop="fInvStd" label="	物料规格" />
									<el-table-column align="center" label="仓库" #default="scope" width="150">
										<el-select v-model="scope.row.fStashId" clearable filterable @change="changeCk">
										<el-option v-for="item in data.ckList"
										:key="item.code"
										:label="item.name"
										:value="item.code+'==='+item.name">
										</el-option>
										</el-select>
										
									</el-table-column>
									<el-table-column prop="fOrderNum" label="订货数" />
									<el-table-column prop="fRowNum" label="订单序号" />
									<el-table-column prop="fScanNum" label="已扫描数" />
									<!-- <el-table-column prop="fSendNum" label="本次发货数" /> -->

									<el-table-column align="center" label="本次发货数" #default="scope" width="120">
										<el-input v-model="from.tableHead.salesOrderVos[scope.$index].fSendNum"></el-input>
									</el-table-column>
									
									<el-table-column align="center" label="操作" #default="scope" width="100">
										<el-button type="danger" @click="delt(scope)">删除</el-button>
									</el-table-column>
								</el-table>
							</el-col>
							<el-col :span="1">
								<el-button type="primary" plain @click="from.tableHead.salesOrderVos.push({})">
									+
								</el-button>
							</el-col>
						</el-row>
					</div>
				</div>
				<!-- <div class="table-foot">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="5">
								<el-form-item label="到货数量总计：" prop="fOrgCategory">
									<el-input disabled />
								</el-form-item>
							</el-col>
						</el-row>
					</div>
				</div> -->
		      </el-carousel-item>
			  <el-carousel-item>
				  <div class="from2">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="4">
								<el-form-item label="客户名称：" prop="fOrgCategory">
									<el-select style="width: 100%" filterable v-model="from.seleV">
										<el-option v-for="item in data.allUserList" :key="item.code" :label="item.name"
											:value="item.name+'-'+(item.code)" />
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="单据日期：" prop="fOrgCategory">
									<el-date-picker type="date" value-format="YYYY-MM-DD"  v-model="from.selectInf.date" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="订单编号：" prop="fOrgCategory">
									<el-input  v-model="from.selectInf.orderCode" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="收货地址：" prop="fOrgCategory">
									<el-input v-model="from.selectInf.sendAddress" />
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item label="订单状态：" prop="fOrgCategory">
									<el-select style="width: 100%" filterable v-model="from.selectInf.state">
										<el-option v-for="item in [{a:'草稿',b:0},{a:'扫描',b:1},{a:'已发货',b:2},{a:'全部',b:''}]" :key="item.b" :label="item.a"
											:value="item.b" />
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="2">
								<div style="width:100%;height: 100%;display: flex;justify-content: flex-end;">
									<el-button type="danger" style="width: 74%;" plain @click="clearSelect">
										重置
									</el-button>
								</div>
							</el-col>
							<el-col :span="2">
								<div style="width:100%;height: 100%;display: flex;justify-content: flex-end;">
									<el-button type="primary" style="width: 74%;" plain @click="selectHis">
										查询
									</el-button>
								</div>
							</el-col>
						</el-row>
					</div>
				</div>
				<div class="table2">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								<el-table :data="data.hisList" border style="width: 100%" @row-dblclick="dbclick">
									<el-table-column align="center" prop="fCustomerName" label="客户名称"  min-width="120" :show-overflow-tooltip="true" />
									<el-table-column align="center" prop="fDate" label="单据日期"  min-width="120" :show-overflow-tooltip="true" />
									<el-table-column align="center" prop="fOrderCode" label="订单编号"  min-width="120" :show-overflow-tooltip="true" />
									<el-table-column align="center" prop="fCusReceiveAddress" label="收货地址"  min-width="120" :show-overflow-tooltip="true" />
									<el-table-column prop="fInvCode" label="物料编号" min-width="120" :show-overflow-tooltip="true" align="center" />
									<el-table-column prop="fInvName" label="物料名称" min-width="120" :show-overflow-tooltip="true" align="center" />
									<el-table-column prop="fInvStd" label="物料规格" min-width="120" :show-overflow-tooltip="true" align="center" />
									<el-table-column prop="xxxx" label="通知单号" align="center" />
									<el-table-column prop="fOrderNum" label="订货数" align="center" />
									<el-table-column prop="fRowNum" label="订单序号" align="center" />
									<el-table-column prop="fScanNum" label="已扫描数" align="center"/>
									<el-table-column prop="fSendNum" label="本次发货数" align="center" width="140" />
									<el-table-column align="center" label="订单状态" #default="scope" width="120">
										{{(scope.row.fOrderState==0)?'草稿':(scope.row.fOrderState==1)?'扫描':'已发货'}}
									</el-table-column>
									<el-table-column align="center" label="操作" #default="scope" width="180">
										<el-button type="danger" @click="delHis(scope)">删除</el-button>
										<el-button :type="(scope.row.fOrderState!=0)?'primary':'warning'" @click="editHis(scope)">{{(scope.row.fOrderState!=0)?'查看':'编辑'}}</el-button>
									</el-table-column>
								</el-table>
							</el-col>
						  <el-col :span="24" v-show="from.pageInf.sumPage>0">
							  <el-pagination style="margin-top: 20px" layout="total, sizes, prev, pager, next, jumper"
							  	:page-size="from.selectInf.size" :total="from.pageInf.sumPage" :current-page="from.selectInf.page"
							  	@current-change="pageSelect" @size-change="pageSizeSelect">
							  </el-pagination>
						  </el-col>
					</el-row>
					</div>
				</div>
				<div class="table-foot">
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="5">
								<el-form-item label="到货数量总计：" prop="fOrgCategory">
									<el-input disabled />
								</el-form-item>
							</el-col>
						</el-row>
					</div>
				</div>
			  </el-carousel-item>
		    </el-carousel>
		<div class="footName">
<!-- 			<el-row :gutter="10">
				<el-col :span="1.5">
					录入人：
				</el-col>
				<el-col :span="2">
					<el-form-item>
						<el-input />
					</el-form-item>
				</el-col>
				<el-col :span="2">
					<el-form-item>
						<el-input />
					</el-form-item>
				</el-col>
			</el-row> -->
		</div>
		<div class="popUp">
			<el-dialog title="新增发货通知单" v-model="popUpShow.addPopUp" width="50%" :draggable="true" >

			  <div class="select-cont">
				  <el-from>
					  <el-row :gutter="10">
						  <el-col :span="6">
							<el-form-item label="客户：">
								<el-select filterable class="m-2" placeholder="Select" v-model="from.select" @change="selectUserDD">
									<el-option v-for="i,j in data.allUserList" :key="i.code" :label="i.name" :value="i.name+'-'+(i.code)" />
								</el-select>
							</el-form-item>
						  </el-col>
						  <el-col :span="24">
							  <el-table :data="data.userOrderList" border style="width: 100%" v-loading="false">
							  	<el-table-column align="center" prop="fCustomerCode" label="客户编码"  min-width="120" :show-overflow-tooltip="true" />
							  	<el-table-column align="center" prop="fCustomerName" label="客户名称"  min-width="120" :show-overflow-tooltip="true"/>
							  	<el-table-column align="center" prop="fOrderAddress" label="发货地址"  min-width="120" :show-overflow-tooltip="true" />
							  	<el-table-column align="center" prop="fOrderCode" label="订单编号" min-width="120" :show-overflow-tooltip="true" />
							  	<el-table-column align="center" label="操作" #default="scope" width="80">
									<el-button type="primary" @click="selectD(scope)">选择</el-button>
							  	</el-table-column>
							  </el-table>
						  </el-col>
					  </el-row>					  
				  </el-from>
			  </div>
			</el-dialog>
			<el-dialog title="修改发货通知单" v-model="popUpShow.edit" width="50%" :draggable="true" >
			  <div class="select-cont">
				  <el-from label-width="150px">
					<el-row :gutter="10">
						<el-col :span="8">
							<el-form-item label="物料编号：" prop="fOrgCategory">
								<el-input disabled v-model="from.his.fromData.fInvCode" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="物料名称：" prop="fOrgCategory">
								<el-input disabled v-model="from.his.fromData.fInvName" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="物料规格：" prop="fOrgCategory">
								<el-input disabled v-model="from.his.fromData.fInvStd" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="仓 库 ： " prop="fOrgCategory">
								<el-select v-model="from.his.fromData.fStashId" clearable filterable>
								<el-option v-for="item in data.ckList"
								:key="item.code"
								:label="item.name"
								:value="item.code+'==='+item.name">
								</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="客户编号：" prop="fOrgCategory">
								<el-select placeholder="请选择客户编号" style="width: 100%" filterable disabled v-model="from.his.fromData.fCustomerCode">
									<el-option v-for="item in data.allUserList" :key="item.code" :label="item.code"
										:value="item.code" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="客户名称：" prop="fOrgCategory">
								<el-input placeholder="请输入客户名称" disabled v-model="from.his.fromData.fCustomerName" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="通知单号：" prop="fOrgCategory">
								<el-input disabled  v-model="from.his.fromData.fOrderNumber" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="通知单日期：" prop="fOrgCategory">
								<el-date-picker disabled type="date" v-model="from.his.fromData.fOrderDate" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="已扫描数：" prop="fOrgCategory">
								<el-input v-model="from.his.fromData.fScanNum" />
							</el-form-item>
						</el-col>
						<el-col :span="16">
							<el-form-item label="收货地址：" prop="fOrgCategory">
								<el-input  v-model="from.his.fromData.fCusReceiveAddress" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="发 货 日 期 ：" prop="fOrgCategory">
								<el-date-picker type="date" value-format="YYYY-MM-DD" v-model="from.his.fromData.fSendDate" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="订单编号：" prop="fOrgCategory">
								<el-input  v-model="from.his.fromData.fOrderCode" disabled />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="收货方：" prop="fOrgCategory">
								<el-input disabled v-model="from.his.fromData.fSender" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label=" 经  办 人 ： " prop="fOrgCategory">
								<el-input  v-model="from.his.fromData.fAgent" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="经办人电话：" prop="fOrgCategory">
								<el-input placeholder="请输入经办人电话" v-model="from.his.fromData.fAgentPhone" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="订货数：" prop="fOrgCategory">
								<el-input placeholder="请输入订货数" v-model="from.his.fromData.fOrderNum" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="本次发货数：" prop="fOrgCategory">
								<el-input placeholder="请输入本次发货数" v-model="from.his.fromData.fSendNum" />
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="发货物流：" prop="fOrgCategory">
								<el-input placeholder="请输入发货物流" v-model="from.his.fromData.fSendLogistics" />
							</el-form-item>
						</el-col>
					</el-row>				  
				  </el-from>
			  </div>
			  <template #footer>
				<span class="dialog-footer">
				  <el-button @click="popUpShow.edit = false">取消</el-button>
				  <el-button type="primary" @click="editReset" v-if="from.his.fromData.fOrderState==0">
					提交
				  </el-button>
				</span>
			  </template>
			</el-dialog>
		</div>
	</div>
</template>

<script setup>
	import { reactive,watch,onMounted,ref } from 'vue';
	import { ElMessage, ElMessageBox } from 'element-plus'
	import ajax from '../../../../public/JavaScript/api/ajax.js'
	let swip=ref()
	let popUpShow=reactive({
		addPopUp:false,
		page:false,
		edit:false
	})
	let data=reactive({
		allUserList:[],
		userOrderList:[],
		hisList:[],
		ckList:[]
	})
	let publicData=reactive({
		dbclickData:{}
	})
	function changeHis(){
		swip.value.setActiveItem(1)
	}
	function changeAdd(){
		popUpShow.addPopUp=true
	}
	/* 重置查询条件 */
	function clearSelect(){
		from.selectInf={
			  "customerCode": "",
			  "customerName": "",
			  "date": "",
			  "orderCode": "",
			  "page": 1,
			  "sendAddress": "",
			  "size": 10,
			  "state": ""
		}
		from.seleV=''
	}
	/* 双击表格行 */
	function dbclick(row,column, event){
		// console.log(row)
		// publicData.dbclickData=row
	}
	/* 打开编辑历史弹窗 */
	function editHis(ev){
		ajax.post('/soc/ssob/'+ev.row.fId,{
			body:{}
		},res=>{
			console.log(res)
			if(res.code==200){
				from.his.fromData=res.data
				popUpShow.edit=true
				selectHis()
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('编辑弹窗打开失败')
		})
	}
	/* 删除历史发货 */
	function delHis(ev){
		if(ev.row.fOrderState==0){
			ElMessageBox.confirm(
			  '是否确认删除?',
			  '警告',
			  {
				confirmButtonText: '是',
				cancelButtonText: '否',
				type: 'error',
			  }
			).then(()=>{
				ajax.post('/soc/dsob/'+ev.row.fId,{body:{}},res=>{
					if(res.code==200){
						ElMessage.success('删除成功')
						data.hisList.splice(ev.$index,1)
					}else{
						ElMessage.error(res.msg)
					}
				})
			})
		}else{
			ElMessage.error('不是草稿状态不允许删除！')
		}
	}
	/* 提交编辑信息 */
	function editReset(){
		ajax.post('/soc/usob',{
			body:from.his.fromData
		},res=>{
			if(res.code==200){
				ElMessage.success('编辑成功')
				popUpShow.edit=false
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('系统错误')
		})
	}
	/* 深拷贝 */
	function sCOPY(start,end){
		for(let i in end){
			start[i]=JSON.parse(JSON.stringify(end[i]))
		}
	}
	/* 获取订单列表 */
	function selectUserDD(ev){
		ajax.post(`/soc/gco?customerCode=${ev.split('-')[1]}`,{body:{}},res=>{
			console.log('查询订单信息：',res)
			if(res.code==200){
				data.userOrderList=res.data
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('服务器异常')
		})
	}
	/* 对象赋空 */
	function clearObj(obj){
		for(let i in obj){
			obj[i]=''
		}
	}
	/* 获取订单信息 */
	function selectD(ev){
		console.log(ev.row)
		// from.tableHead.salesOrderHead.fCustomerCode=ev.row.fCustomerCode
		// from.tableHead.salesOrderHead.fCustomerName=ev.row.fCustomerName
		// from.tableHead.salesOrderHead.fOrderAddress=ev.row.fOrderAddress
		// from.tableHead.salesOrderHead.fOrderCode=ev.row.fOrderCode
		ajax.post(`/soc/gcboc?orderCode=${ev.row.fOrderCode}`,{body:{}},res=>{
			if(res.code==200){
				from.tableHead.salesOrderVos=res.data.salesOrderBodyList
				// from.tableHead.salesOrderHead=res.data.salesOrderHead
				for(let i in res.data.salesOrderHead){
					from.tableHead.salesOrderHead[i]=res.data?.salesOrderHead[i] || from.tableHead.salesOrderHead[i]
				}
				popUpShow.addPopUp=false
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('系统错误')
		})
	}
	/* 保存订单信息 */
	function confirmOrder(){
		ajax.post('/soc/sco',{
			body:{
				salesOrderBodyList:from.tableHead.salesOrderVos,
				salesOrderHead:{
					...(from.tableHead.salesOrderHead),
					fSendAddress:(from.tableHead.salesOrderHead.fSendAddress.length>0)?(from.tableHead.salesOrderHead.fSendAddress):(from.tableHead.salesOrderHead.fCusReceiveAddress)
				}
			}
		},res=>{
			console.log(res)
			if(res.code==200){
				// clearObj(from.tableHead.salesOrderHead)
				from.tableHead.salesOrderVos=[]
				selectD({row:{fOrderCode:from.tableHead.salesOrderHead.fOrderCode}})
				ElMessage.success('提交成功')
				from.tableHead.salesOrderHead.fOrderCode=''
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('系统错误')
		})
	}
	/* 删除列表 */
	function delt(ev){
		from.tableHead.salesOrderVos.splice(ev.$index,1)
	}
	/* 查询历史发货信息 */
	function selectHis(ev){
		if(from.seleV.length>0){
			from.selectInf.customerCode=from.seleV.split('-')[1]
			from.selectInf.customerName=from.seleV.split('-')[0]
		}
		ajax.post('/soc/gso',{
			body:from.selectInf
		},res=>{
			console.log(res)
			if(res.code==200){
				ElMessage.success('查询成功')
				from.pageInf.sumPage=res.data.totalCount
				data.hisList=res.data.list
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('系统错误')
		})
	}
	/* 分页查询 */
	function pageSelect(ev){
		from.selectInf.page=ev
		selectHis()
	}
	function pageSizeSelect(ev){
		from.selectInf.size=ev
		selectHis()
	}
	let from =reactive({
		select:'',
		tableHead:{
			  "salesOrderHead": {
				"fAgent": "",
				"fAgentPhone": "",
				"fCustomerCode": "",
				"fCustomerName": "",
				"fOrderCode": "",
				"fOrderDate": "",
				"fOrderNumber": "",
				"fSendAddress": "",
				"fSendDate": "",
				"fSendLogistics": "",
				"fSender": "",
				"fCusReceiveAddress":""
			  },
			  "salesOrderVos": []
			},
		selectInf:{
			  "customerCode": "",
			  "customerName": "",
			  "date": "",
			  "orderCode": "",
			  "page": 1,
			  "sendAddress": "",
			  "size": 10,
			  "state": ""
		},
		seleV:'',
		pageInf:{
			pageSize:10,
			page:1,
			sumPage:0
		},
		his:{
			khNum:'',
			fromData:{
			  "fAgent": "",
			  "fAgentPhone": "",
			  "fCustomerCode": "",
			  "fCustomerName": "",
			  "fDate": "",
			  "fId": "",
			  "fInvCode": "",
			  "fInvName": "",
			  "fInvStd": "",
			  "fOrderCode": "",
			  "fOrderDate": "",
			  "fOrderNum": 0,
			  "fOrderNumber": "",
			  "fOrderState": 0,
			  "fRowNum": 0,
			  "fScanNum": 0,
			  "fSendAddress": "",
			  "fSendDate": "",
			  "fSendLogistics": "",
			  "fSendNum": 0,
			  "fSender": "",
			  "fCusReceiveAddress":""
			}
		}
	})
	onMounted(()=>{
		/* 获取所有客户信息 */
		ajax.post('/soc/gc',{
			body:{}
		},res=>{
			console.log('获取所有客户信息：',res)
			if(res.code==200){
				data.allUserList=res.data
			}else{
				ElMessage.error(res.msg)
			}
		},err=>{
			ElMessage.error('服务器异常')
		})

		ajax.post('/pag/gr',{
			body:{}
		},res=>{
			data.ckList=res.data
		})
	})
	function add(){
		swip.value.setActiveItem(0)
	}
	function SM_wlbh(ev){
		if(ev.row.fInvCode.length>0){
			ajax.post('/soc/gibc?invCode='+(ev.row.fInvCode),{
				body:{
					invCode:ev.row.fInvCode
				}
			},res=>{
				if(res.code==200){
					ElMessage.success('查询成功')
					from.tableHead.salesOrderVos[ev.$index]={
						fInvCode:ev.row.fInvCode,
						fInvName:(res.data[0]?.invName || ''),
						fInvStd:(res.data[0]?.invStd || ''),
						fOrderNum:0,
						fRowNum:0,
						fSendNum:1,
						fScanNum:0
					}
				}else{
					ElMessage.error(res.msg || '系统错误')
				}
			},err=>{
				ElMessage.error(err.msg || '服务器错误')
			})
		}else{
			ElMessage.error('物料编码不能为空')
		}
	}
	function select_name(){
		ajax.post('/soc/gcc?customerCode='+(from.tableHead.salesOrderHead.fCustomerCode),{
			body:{
				customerCode:from.tableHead.salesOrderHead.fCustomerCode
			}
		},res=>{
			if(res.code==200){
				from.tableHead.salesOrderHead.fCustomerName=res.data.code
			}else{
				ElMessage.error(res.msg || '查询异常')
			}
		},err=>{
			ElMessage.error(err.msg || '查询异常')
		})
	}
	function changeCk(ev){
		console.log(ev)
	}
</script>

<style lang="less" scoped>
	@import url("./NoticeOfShipment.less");
</style>
